from PyPDF2 import PdfFileReader,PdfFileMerger

def pdf_merger(in_pdfs,out_pdf):
    # 初始化
    merger = PdfFileMerger()
    # 循环，合并
    for in_pdf in in_pdfs:
        with open(in_pdf,'rb') as pdf:
            merger.append(PdfFileReader(pdf))
    merger.write(out_pdf)

if __name__ == '__main__':
    in_pdfs = ['放要合并的PDF文件名称，注意顺序']
    out_pdf = '输出文件'
    pdf_merger(in_pdfs, out_pdf)